//
//  panel.m
//  Void Dead
//
//  Created by Sidney Just on 04.07.09.
//  Copyright 2009 by Sidney Just
//  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; 
//  either version 3 of the License, or (at your option) any later version.
//  
//  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
//  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//  

#import "panel.h"
#import "vector.h"
#import "Engine.h"

@implementation VD_Panel
@synthesize layer, texture, changeByCam;
@synthesize pos_x, pos_y, rotation, scale, size, atlasSize_x, atlasSize_y, atlasPos_x, atlasPos_y;
@synthesize animated, animation;
@synthesize skill_a, skill_b, userData, visible, parallaxScrolled;

- (id)initWithEngine:(VD_Engine *)eng {
	if(self = [super init])
	{
		renderEngine = eng;
		
		pos_x = 0;
		pos_y = 0;
		scale = [[VD_Vector alloc] init];
		size = [[VD_Vector alloc] init];
		
		animation = [[VD_Animation alloc] init];
		
		animated = NO;
		
		texture = -1;
		
		changeByCam = YES;
		
		visible = YES;
		
		parallaxScrolled = NO;
		
		rotation = 0;
		
		atlasSize_x = 0.0f;
		atlasSize_y = 0.0f;
		atlasPos_x = 1.0f;
		atlasPos_y = 1.0f;
		
		skill_a = 0;
		skill_b = 0;
		userData = NULL;
		
		scale.x = 1;
		scale.y = 1;
	}
	return self;
}

- (void)dealloc {
	[scale release];
	[size release];
	[animation release];
	
	[super dealloc];
}

- (BOOL)isInScreenBounds {
	return ((pos_x < renderEngine.backingWidth+size.x) && (pos_x+size.x > 0-size.x) &&
			(pos_y < renderEngine.backingHeight+size.y) && (pos_y+size.y > 0-size.y));
}


- (BOOL)posInMe:(CGPoint)pos_ {
	return ((pos_.x > pos_x && pos_.x < pos_x+size.x) && (pos_.y > pos_y && pos_.y < pos_y+size.y));
}

@end
